home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #1 / Amiga Plus CD - 2000 - No. 1.iso / Tools / Text / Edit / GoldED-Demo / installdata / golded / developer / api / include / apilib.h
Encoding:
C/C++ Source or Header  |  1999-12-03  |  19.4 KB  |  397 lines

  1. #ifndef APILIB_H
  2. #define APILIB_H
  3.  
  4. /*
  5. **      $Filename: developer/api/include/apilib.h
  6. **      $Release:  6.2.3
  7. **
  8. **      API definitions; this file does not include any GoldED-specific
  9. **      code (see developer/include/editor.h for GoldED-specific code).
  10. **
  11. **      (C) Copyright 1999 Dietmar Eilert
  12. **          All Rights Reserved
  13. */
  14.  
  15. #ifndef EXEC_TYPES_H
  16. #include <exec/types.h>
  17. #endif
  18.  
  19. #ifndef EXEC_LISTS_H
  20. #include <exec/lists.h>
  21. #endif
  22.  
  23. #ifndef EXEC_LIBRARIES_H
  24. #include <exec/libraries.h>
  25. #endif
  26.  
  27. #ifndef INTUITION_INTUITION_H
  28. #include <intuition/intuition.h>
  29. #endif
  30.  
  31. #ifndef UTILITY_TAGITEM_H
  32. #include <utility/tagitem.h>
  33. #endif
  34.  
  35. #ifndef WORKBENCH_WORKBENCH_H
  36. #include <workbench/workbench.h>
  37. #endif
  38.  
  39. #ifndef MAKE_ID
  40. #define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
  41. #endif
  42.  
  43. #define API_MAGIC  MAKE_ID('A','P','I','5')
  44.  
  45. /* library base */
  46.  
  47. struct APIBase {
  48.  
  49.     struct Library       Library;                    /* standard library */
  50.     UWORD                pad;                        /* we are now longwod aligned */
  51.     ULONG                Magic;                      /* used to recognize API libraries */
  52. };
  53.  
  54.  
  55. #define API_INTERFACE_VERSION 6
  56.  
  57.  
  58. /* -------------------------------- APIMessage ---------------------------------
  59.  
  60.  API messages are sent from a host (or an instance of the host) to plug-ins.
  61.  API messages are linked (api_Next; may be NULL). The plug-in has to check the
  62.  api_State field before processing the message (must be API_STATE_NOTIFY).
  63.  Check the api_Class field to determine the basic message type (e.g.
  64.  API_CLASS_SCREEN if the message is related to screen handling). Check the
  65.  api_Action field to determine the actual command (e.g. API_ACTION_HIDE if
  66.  the host wants you to close your windows). A plug-in should update the
  67.  api_Error field after having processed the message and possibly set
  68.  api_State to API_STATE_CONSUMED (if the message has been processed and
  69.  should not be passed to other plug-ins).
  70.  
  71. */
  72.  
  73. struct APIMessage {
  74.  
  75.     /* info slots */
  76.  
  77.     ULONG                api_State;                  /* set by host, updated by plug-in: message state (see below) */
  78.     struct APIMessage   *api_Next;                   /* set by host: next message */
  79.     struct APIInstance  *api_Instance;               /* set by host: instance-related data */
  80.  
  81.     /* command slots */
  82.  
  83.     ULONG                api_Class;                  /* set by host: notify class (see below) */
  84.     ULONG                api_Action;                 /* set by host: notify code  (see below) */
  85.     ULONG                api_Qualifier;              /* set by host: intuition qualifier of last input event */
  86.     APTR                 api_Data;                   /* set by host: all-purpose slot; usage depends on api_Class */
  87.     UBYTE               *api_Command;                /* set by host: command string for plug-in (read-only), command part uppercase */
  88.  
  89.     /* return code slots */
  90.  
  91.     LONG                 api_RC;                     /* set by plug-in: primary return code */
  92.     UBYTE               *api_CommandResult;          /* set by plug-in: result text */
  93.     UBYTE               *api_CommandError;           /* set by plug-in: error text */
  94.     ULONG                api_Error;                  /* set by plug-in: return code (see below) */
  95.     ULONG                api_Refresh;                /* set by plug-in: display refresh request */
  96.     struct APIOrder     *api_Order;                  /* set by plug-in: order(s) for host program */
  97.     UBYTE               *api_Status;                 /* set by plug-in: status text (displayed by host in status bar) */
  98.     UWORD                api_Processed;              /* set by plug-in: processed counter */
  99. };
  100.  
  101.  
  102. /* supported state values (api_State) */
  103.  
  104. #define API_STATE_IGNORE        0                    /* this message should be ignored */
  105. #define API_STATE_NOTIFY        1                    /* this message should be processed */
  106. #define API_STATE_CONSUMED      2                    /* message has been processed  and consumed (not to be processed by other plug-ins) */
  107.  
  108. /* api action classes the plug-in listens to (api_Class) */
  109.  
  110. #define API_CLASS_SCREEN        (1L<<1)              /* screen handling  */
  111. #define API_CLASS_KEY           (1L<<2)              /* keyboard events */
  112. #define API_CLASS_COMMAND       (1L<<3)              /* command execution */
  113. #define API_CLASS_SYSTEM        (1L<<6)              /* standard events */
  114. #define API_CLASS_IO            (1L<<7)              /* input and output */
  115. #define API_CLASS_CONTAINER     (1L<<8)              /* container events */
  116. #define API_CLASS_WORKSPACE     (1L<<9)              /* workspace events */
  117.  
  118. /* Supported qualifiers for API_CLASS_KEY events received by plug-in (api_Action) */
  119.  
  120. #define API_ACTION_VANILLAKEY   1                    /* request to process a key (key code in api_Data) */
  121. #define API_ACTION_RAWKEY       2                    /* request to process a key (key code in api_Data) */
  122. #define API_ACTION_MOUSEBUTTON  3                    /* request to process a key (key code in api_Data: bit 0-2: qualifier, bit 3: doubleclick, bit 4: set if middle button, bit 5: set if wheel button) */
  123.  
  124. /* Supported qualifiers for API_CLASS_SCREEN events received by plug-in */
  125.  
  126. #define API_ACTION_HIDE         1                    /* request to close the output (host is about to close the screen) */
  127. #define API_ACTION_SHOW         2                    /* request to show  the output */
  128.  
  129. /* Supported qualifiers for API_CLASS_COMMAND events received by plug-in (api_Action) */
  130.  
  131. #define API_ACTION_COMMAND      1                    /* request to process a command (command string in api_Command) */
  132.  
  133. /* Supported qualifiers for API_CLASS_SYSTEM events received by plug-in (api_Action) */
  134.  
  135. #define API_ACTION_WELCOME      1                    /* notification: welcome */
  136. #define API_ACTION_EXIT         2                    /* notification: termination pending */
  137. #define API_ACTION_SAVEPREFS    4                    /* request to save preferences */
  138. #define API_ACTION_SIGNAL       8                    /* request to process signal(s) (signal mask in api_Data) */
  139.  
  140. /* Supported qualifiers for API_CLASS_IO events received by plug-in (api_Action) */
  141.  
  142. #define API_ACTION_SAVE         1                    /* notification: save operation pending  (pointer to file name in api_Data) */
  143. #define API_ACTION_CREATED      2                    /* notification: a file has been saved   (pointer to file name in api_Data) */
  144. #define API_ACTION_READ         4                    /* notification: a file has been loaded  (pointer to file name in api_Data) */
  145. #define API_ACTION_DELETED      8                    /* notification: a file has been deleted (pointer to file name in api_Data) */
  146.  
  147. /* Supported qualifiers for API_CLASS_CONTAINER events received by plug-in (api_Action) */
  148.  
  149. #define API_ACTION_DETACH       1                   /* request to detach interface */
  150. #define API_ACTION_ATTACH       2                   /* request to attach interface */
  151. #define API_ACTION_PAINT        4                   /* request to paint the interface */
  152. #define API_ACTION_INPUTEVENT   8                   /* request to process an input event (pointer to APIInputEvent in api_Data) */
  153. #define API_ACTION_REFRESH      16                  /* request to refresh the interface (see intuition.doc/BeginRefresh() for restrictions) */
  154.  
  155. /* Supported qualifiers for API_CLASS_WORKSPACE events received by plug-in (api_Action) */
  156.  
  157. #define API_ACTION_OPEN         1                    /* notification: a document has been opened   (pointer to host-specific document context in api_Data; see api_Environment) */
  158. #define API_ACTION_CLOSE        2                    /* notification: a document has been closed   (pointer to host-specific document context in api_Data; see api_Environment) */
  159. #define API_ACTION_NAME         4                    /* notification: a document has been renamed  (pointer to host-specific document context in api_Data; see api_Environment) */
  160. #define API_ACTION_FREEZE       8                    /* notification: a document has been frozen   (pointer to host-specific document context in api_Data; see api_Environment) */
  161. #define API_ACTION_UNFREEZE     16                   /* notification: a document has been unfrozen (pointer to host-specific document context in api_Data; see api_Environment) */
  162.  
  163. /* api_Error return codes (to be set by plug-in) */
  164.  
  165. #define API_ERROR_OK            0                    /* message successfully processed */
  166. #define API_ERROR_FAIL          1                    /* processing failed */
  167. #define API_ERROR_UNKNOWN       2                    /* unsupported api_Class/api_Action packet */
  168.  
  169. /* api_Refresh values (to be requested by plug-in) */
  170.  
  171. #define API_REFRESH_DISPLAY     (1L<<1)              /* redraw entire display */
  172. #define API_REFRESH_LINE        (1L<<2)              /* redraw current line */
  173. #define API_REFRESH_SYNC        (1L<<3)              /* sync view */
  174. #define API_REFRESH_NOMARKER    (1L<<4)              /* hide the selection */
  175. #define API_REFRESH_MARKER      (1L<<8)              /* refresh the selection */
  176.  
  177.  
  178. /* ---------------------------------- APIHost ----------------------------------
  179.  
  180.  Host description (read-only); provided by host. api_Environment is a pointer
  181.  to a host-specific "document context" (see editor.h for golded).
  182.  
  183. */
  184.  
  185. struct APIHost {
  186.  
  187.     ULONG                api_APIVersion;             /* interface standard supported by host */
  188.     ULONG                api_Version;                /* release code */
  189.     UBYTE               *api_Serial;                 /* serial code of host program (or 0 if unregistered) */
  190.     UBYTE               *api_Name;                   /* application name */
  191.     UBYTE               *api_Info;                   /* application info */
  192.     APTR                 api_Environment;            /* host-specific document context */
  193.     UBYTE               *api_Rexx;                   /* rexx port */
  194.     APTR                 api_Reserved;               /* reserved */
  195.  
  196.     /* may be extended in the future */
  197. };
  198.  
  199.  
  200. /* -------------------------------- APIInstance --------------------------------
  201.  
  202.  Environment description (read-only); provided by the host instance. Please note
  203.  that all fields (including api_Window->RPort) are read-only.
  204.  
  205. */
  206.  
  207. struct APIInstance {
  208.  
  209.     struct APIHost      *api_Host;                   /* host application */
  210.     UBYTE               *api_Name;                   /* instance name (typically the document name) */
  211.     APTR                 api_Environment;            /* configuration (host-specific; see golded:developer/include/golded.h) */
  212.     struct Screen       *api_Screen;                 /* screen used by instance or NULL */
  213.     struct Window       *api_Window;                 /* window used by instance or NULL */
  214.     struct APIContainer *api_Container;              /* container area or NULL */
  215.     struct TextAttr     *api_TextAttr;               /* recommended font */
  216.     ULONG                api_Reserved;               /* reserved */
  217.  
  218.     /* may be extended in the future */
  219. };
  220.  
  221.  
  222. /* --------------------------------- APIClient ---------------------------------
  223.  
  224.  Plug-in description. This is passed to the host program. Please note that
  225.  the host may or may not be able to fulfill the area request and that the
  226.  container dimensions provided by the host may not match your requests (the
  227.  host will automatically use the dimensions preferred by the user if the
  228.  plug-in has been used before). The actual container dimensions can be found
  229.  in the next APIMessage. The host will use the api_Image (recommended size:
  230.  16x16) instead of the name to represent the iconified plug-in in the toolbar.
  231.  
  232.  Note: plug-in must have unique names because the name is used when the host
  233.  decides to restore previously used dimensions.
  234.  
  235. */
  236.  
  237.  
  238. struct APIClient {
  239.  
  240.     ULONG                api_APIVersion;             /* interface standard supported by plug-in */
  241.     ULONG                api_Version;                /* release code */
  242.     UBYTE               *api_Name;                   /* unique plug-in name */
  243.     UBYTE               *api_Info;                   /* plug-in info */
  244.     UBYTE              **api_Commands;               /* command list (NULL-terminated) */
  245.     ULONG                api_Serial;                 /* serial code of plug-in */
  246.     ULONG                api_Classes;                /* class request */
  247.     struct APIArea      *api_Area;                   /* area request */
  248.     ULONG                api_Signals;                /* signals to wait for */
  249.     UBYTE               *api_Image;                  /* image representing iconified plug-in (file name, optional) */
  250.     ULONG                api_Reserved;               /* reserved */
  251.  
  252.     /* private plug-in data may follow */
  253. };
  254.  
  255.  
  256. /* ------------------------------------ APIOrder -------------------------------
  257.  
  258.  Orders are created by plug-ins and attached to APIMessages after a message has
  259.  been processed to send "orders" and "commands" back to the host. The contents
  260.  of the order's data block and the meaning of the flags (which should describe
  261.  what is in the data block) are host specific. A few standard order types are
  262.  however supported by all hosts; defines for these order types can be found
  263.  below. The host will process the order and then call the plug-in's APIFree()
  264.  function so that the plug-in can free memory and other resources allocated for
  265.  the order.
  266.  
  267. */
  268.  
  269. struct APIOrder {
  270.  
  271.     struct APIOrder     *api_Next;                   /* next order or NULL */
  272.     APTR                 api_Data;                   /* host-specific (see developer/include/editor.h for GoldED) */
  273.     ULONG                api_Flags;                  /* host-specific (see developer/include/editor.h for GoldED) */
  274.  
  275.     /* private plug-in data may follow */
  276. };
  277.  
  278. /* standard values for api_Flags supported by all hosts */
  279.  
  280. #define API_ORDER_ATTACH      (2L<<24)               /* api_Data contains the gadget list */
  281. #define API_ORDER_DETACH      (3L<<24)               /* api_Data contains the gadget list */
  282. #define API_ORDER_DTATTACH    (4L<<24)               /* api_Data contains the datatype list */
  283. #define API_ORDER_DTDETACH    (5L<<24)               /* api_Data contains the datatype list */
  284.  
  285.  
  286. /* ---------------------------------- APIArea ----------------------------------
  287.  
  288.  Area request. The host application will create a new container for each area
  289.  request (if possible). A container is a reserved rendering space provided by
  290.  a host instance (typically a host window). You can set the initial width or
  291.  the initial height. Only one of these values will be used because containers
  292.  are always aligned with window borders so that either size or height depend
  293.  on the actual window dimensions. Dimensions requested by the plug-in may or
  294.  may not be respected by the host application: The host program usually
  295.  overrides the alignment and dimension values with the values preferred by
  296.  the user if the plug-in has been used before. The actual dimensions can be
  297.  read from APIMessage->APIInstance->APIContainer in subsequent APIMessage
  298.  messages.
  299.  
  300. */
  301.  
  302. struct APIArea {
  303.  
  304.     UWORD                api_Width;                  /* initial size request (width) */
  305.     UWORD                api_Height;                 /* initial size request (height) */
  306.     UWORD                api_UnitsX;                 /* units used in initial size request (see below) */
  307.     UWORD                api_UnitsY;                 /* units used in initial size request (see below) */
  308.     UWORD                api_Alignment;              /* alignment flags (see below) */
  309.     UWORD                api_Style;                  /* container style (see below) */
  310.     ULONG                api_IDCMP;                  /* IDCMP mask (requested IDCMP events) */
  311.     ULONG                api_Reserved[16];           /* reserved for future use */
  312. };
  313.  
  314. /* special size value (api_Width, api_Height) */
  315.  
  316. #define API_SIZE_UNDEFINED    0                      /* size undefined (host will use the host-specific default size) */
  317.  
  318. /* unit flags (api_UnitsX, apiUnitsY) determine the meaning of the api_Width/api_Height */
  319.  
  320. #define API_UNITS_PIXEL       0                      /* absolute size (pixel) */
  321. #define API_UNITS_FONT        1                      /* absolute size (characters) */
  322. #define API_UNITS_PERCENT     2                      /* relative size (0-100%) */
  323.  
  324. /* container alignment flags (api_Alignment) */
  325.  
  326. #define API_ALIGN_TOP         0
  327. #define API_ALIGN_BOTTOM      1
  328. #define API_ALIGN_LEFT        2
  329. #define API_ALIGN_RIGHT       3
  330.  
  331. /* container styles (api_Style) */
  332.  
  333. #define API_STYLE_STANDARD    0
  334. #define API_STYLE_BORDERLESS  (1L<<1)
  335. #define API_STYLE_NODRAGBAR   (1L<<2)
  336. #define API_STYLE_NOSIZEBAR   (1L<<3)
  337.  
  338. /* ------------------------------- APIContainer --------------------------------
  339.  
  340.  Container description (provided by the host). This structure describes the
  341.  actual dimensions of the container provided by the host application. All
  342.  values are read-only. Possible values for api_Alignment and api_Style are
  343.  similar to those defined for APIAreaRequest (see above). Note that plug-ins
  344.  should use api_RPort for rendering and may not use the window's rastport
  345.  (they may specifically not set pens, fonts, patterns or draw modes for the
  346.  window's RastPort).
  347.  
  348. */
  349.  
  350. struct APIContainer {
  351.  
  352.     struct Rectangle    *api_Dimensions;             /* dimensions of rendering area or NULL if fully obscured */
  353.     struct Rectangle    *api_Clipping;               /* dimensions of clipping  area or NULL if fully obscured */
  354.     UWORD                api_Alignment;              /* alignment flags */
  355.     UWORD                api_Style;                  /* container style */
  356.     struct RastPort     *api_RPort;                  /* local copy of window's rastport */
  357.     struct DrawInfo     *api_DrawInfo;               /* pens */
  358.     UWORD                api_Namespace;              /* offset for gadget IDs (each plug-in may have 255 gadgets) */
  359.     APTR                 api_VisualInfo;             /* visual info of host screen */
  360.     struct TextAttr     *api_TextAttr;               /* recommended font */
  361.     ULONG                api_IDCMP;                  /* IDCMP signal request */
  362.     APTR                 api_Reserved;               /* reserved */
  363.  
  364.     /* may be extended in the future */
  365. };
  366.  
  367.  
  368. /* ------------------------------- APIInputEvent -------------------------------
  369.  
  370.  Input event description. Provided by the host, read-only. Plug-ins listening to
  371.  the API_CLASS_CONTAINER class see all input events of the host instance (e.g.
  372.  intuiticks and mouse clicks) but should process and consume only input events
  373.  directly related to the container. Note that some events start "in" the
  374.  container but end "outside" the container. For example, a mouse click can start
  375.  in the container (button pressed while mouse is over the container) but end
  376.  outside the container (button released outside the container). It's up to the
  377.  plug-in to make a good decision how such events are handled.
  378.  
  379. */
  380.  
  381. struct APIInputEvent {
  382.  
  383.     struct Window       *api_IDCMPWindow;            /* idcmp window */
  384.     ULONG                api_IDCMPClass;             /* idcmp class */
  385.     UWORD                api_IDCMPCode;              /* idcmp code */
  386.     APTR                 api_IDCMPAddress;           /* idcmp address */
  387.     UWORD                api_IDCMPQualifier;         /* idcmp qualifier */
  388.     ULONG                api_IDCMPSeconds;           /* idcmp time stamp */
  389.     ULONG                api_IDCMPMicros;            /* idcmp time stamp */
  390.     UWORD                api_IDCMPX;                 /* mouse position (relative to host window) */
  391.     UWORD                api_IDCMPY;                 /* mouse position (relative to host window) */
  392.  
  393.     /* may be extended in the future */
  394. };
  395.  
  396. #endif
  397.